﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Domain.Models;

namespace JXT.PrimaryKey.Batman.Domain.Specifications.Expressions
{
    public class PagedExpressionSpecification<TEntity> :
        OrderedExpressionSpecification<TEntity>, IPagedSpecification<TEntity>
        where TEntity : IEntity
    {
        private static readonly int _defaultPageSize = 20;
        private static readonly int _defaultPageIndex = 1;

        public bool IsEnablePaged { get; set; }

        //public int RecordCount { get; set; }

        private int _pageSize = _defaultPageSize;
        public int PageSize
        {
            get { return _pageSize; }
            set
            {
                if (value > 0)
                    _pageSize = value;
            }
        }

        private int _pageIndex = _defaultPageIndex;
        public int PageIndex
        {
            get { return _pageIndex; }
            set
            {
                if (value > 0)
                    _pageIndex = value;
            }
        }

        //public int PageCount
        //{
        //    get {
        //        return RecordCount % PageSize == 0 ?
        //            RecordCount / PageSize :
        //            RecordCount / PageSize + 1;
        //    }
        //}
    }
}
